package org.arga.empresa.model.useradmin;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * Model object that describes a group of users.
 * 
 * @author aflores@arga-inc.com
 * @since Jan 23, 2010 09:49:15 PM 
 */
@Entity
@Table(name="groups")
public class Group {
	private Long m_id;
	private String m_name;
	private String m_description;
	private List<User> m_users;

	/**
     * {@inheritDoc}
	 */
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long getId() {
		return m_id;
	}

	/**
	 * {@inheritDoc}
	 */
	public void setId(Long id) {
		m_id = id;
	}

	/**
	 * Retrieves the name of this group.
	 * @return the name
	 */
	@Column(length=50, unique=true, nullable=false)
	public String getName() {
		return m_name;
	}

	/**
	 * Sets the name of this group.
	 * @param name the name to set
	 */
	public void setName(String name) {
		m_name = name;
	}

	/**
	 * Retrieves the description of this group.
	 * @return the description
	 */
	@Column(length=4000)
	public String getDescription() {
		return m_description;
	}

	/**
	 * Sets the description of this group.
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		m_description = description;
	}

	/**
	 * Retrieves the users of this group.
	 * @return the users
	 */
	@ManyToMany
	@JoinTable(name="users_groups")
	public List<User> getUsers() {
		return m_users;
	}

	/**
	 * Sets the users this group contains.
	 * @param users the users to set
	 */
	public void setUsers(List<User> users) {
		m_users = users;
	}
}
